################################################################################
__author__ = 'zhixian'

################################################################################
import cherrypy
import webpages

################################################################################
@cherrypy.expose
def index():
    """Handler for HTTP-GET to /logout"""
    # TODO: Add another logic here that says that if user is already logged out
    # redirect user to root page
    #raise cherrypy.HTTPRedirect(url)

    cherrypy.session['SESSION_USERNAME'] = None
    ctx = {
        '__name__': __name__
    }
    return webpages.page_output(__name__, None)

@cherrypy.expose
def authenticate(username, password):
    """Handler for HTTP-POST to /login/authenticate
    Status: TODO
    """
    cherrypy.session['SESSION_USERNAME'] = username
    cherrypy.log("Entered {0} with password {1}".format(username, password))
    return "Entered {0} with password {1}".format(username, password)
